#include "gd32f30x.h"
#include "stdint.h"
#include "stdio.h"
#include "DevicesUID.h"

char *pucMcuUIDRead(void)
{
    static char ucUIDBuff[25] = {0};
    uint8_t *pIDAddress = (uint8_t *)CHIP_UID_BASE, i = 0;

    if(ucUIDBuff[0] == 0)
    {
        for(i = 0; i < 12; ++i)
            sprintf(&ucUIDBuff[i * 2], "%02X", *pIDAddress++);
    }

    return ucUIDBuff;
}

uint32_t uiMcuTypeUIDRead(void)
{
    uint32_t *puiDeviceIdAddr = NULL;

    puiDeviceIdAddr = (uint32_t *)(DEVICE_ID_REGISTER);

    return *puiDeviceIdAddr;
}

uint32_t ucMcuHardIDRead(void)
{
    static uint8_t st_ucID = 0;

    if(st_ucID == 0)
    {
        st_ucID = 1;
    }

    return st_ucID;
}
